import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/event/_.dart';
import 'package:thinking/utils/_.dart';

class Splash extends StatefulWidget{
  @override
  _Splash createState() =>_Splash();
}

class _Splash extends State<Splash>{

  @override
  void initState() {
    super.initState();
    Config.eventBus.on<PermissionEvent>().listen((event)  {
      if(event.update){
        Timer(Duration(seconds: 3), (){
          Modular.to.pushReplacementNamed('/welCome');
        });
      }else{

      }
    });

    AuthorityApplication.init(context: context);
  }




  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        Container(
          height: Screen.height(context),
          width: Screen.width(context),
          color: Colors.white,
        ),
        Positioned(
          bottom: 30,
          child:ClipRRect(
            borderRadius: BorderRadius.circular(7.0),
            child: Image(
              image: AssetImage(
                Images.libStaticImgSplash,
              ),
              height: Screen.setWidth(35.0),
              width: Screen.setWidth(35.0),
              fit: BoxFit.cover,
            ),
          )
        )
      ],
    );
  }
}